home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / x / volume3 / awm2 / part07 < prev    next >
Encoding:
Internet Message Format  |  1989-02-20  |  54.7 KB

  1. Path: uunet!lll-winken!ames!pasteur!ucbvax!decwrl!wyse!mikew
  2. From: mikew@wyse.wyse.com (Mike Wexler)
  3. Newsgroups: comp.sources.x
  4. Subject: v03i023:  Ardent Window Manager, Patchlevel 9, Part07/12
  5. Message-ID: <2073@wyse.wyse.com>
  6. Date: 20 Feb 89 22:24:40 GMT
  7. Organization: Wyse Technology, San Jose
  8. Lines: 1759
  9. Approved: mikew@wyse.com
  10.  
  11. Submitted-by: kmw@ardent (Ken Wallich)  
  12. Posting-number: Volume 3, Issue 23
  13. Archive-name: awm2/part07
  14.  
  15. #! /bin/sh
  16. # This is a shell archive.  Remove anything before this line, then unpack
  17. # it by saving it into a file and typing "sh file".  To overwrite existing
  18. # files, type "sh file -c".  You can also feed this as standard input via
  19. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  20. # will see the following message at the end:
  21. #        "End of archive 7 (of 12)."
  22. # Contents:  Cursors.c Icons.c Makefile.rtl RubberBand.c
  23. #   menus/rtlmenu.c
  24. # Wrapped by mikew@wyse on Fri Feb 17 10:50:27 1989
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. if test -f 'Cursors.c' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'Cursors.c'\"
  28. else
  29. echo shar: Extracting \"'Cursors.c'\" \(4232 characters\)
  30. sed "s/^X//" >'Cursors.c' <<'END_OF_FILE'
  31. X
  32. X
  33. X
  34. X#ifndef lint
  35. Xstatic char *rcsid_StoreCursors_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/Cursors.c,v 1.1 89/01/23 15:34:10 jkh Exp $";
  36. X#endif    lint
  37. X
  38. X#include "X11/copyright.h"
  39. X/*
  40. X *
  41. X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  42. X *
  43. X * Copyright 1987 by Jordan Hubbard.
  44. X *
  45. X *
  46. X *                         All Rights Reserved
  47. X *
  48. X * Permission to use, copy, modify, and distribute this software and its
  49. X * documentation for any purpose and without fee is hereby granted,
  50. X * provided that the above copyright notice appear in all copies and that
  51. X * both that copyright notice and this permission notice appear in
  52. X * supporting documentation, and that the name of Ardent Computer
  53. X * Corporation or Jordan Hubbard not be used in advertising or publicity
  54. X * pertaining to distribution of the software without specific, written
  55. X * prior permission.
  56. X *
  57. X */
  58. X
  59. X/*
  60. X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
  61. X *
  62. X *                         All Rights Reserved
  63. X *
  64. X * Permission to use, copy, modify, and distribute this software and its
  65. X * documentation for any purpose and without fee is hereby granted,
  66. X * provided that the above copyright notice appear in all copies and that
  67. X * both that copyright notice and this permission notice appear in
  68. X * supporting documentation, and that the name of Digital Equipment
  69. X * Corporation not be used in advertising or publicity pertaining to
  70. X * distribution of the software without specific, written prior permission.
  71. X *
  72. X *
  73. X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  74. X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  75. X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  76. X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  77. X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  78. X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  79. X * SOFTWARE.
  80. X */
  81. X
  82. X
  83. X
  84. X/*
  85. X * MODIFICATION HISTORY
  86. X *
  87. X * 000 -- M. Gancarz, DEC Ultrix Engineering Group
  88. X * 001 -- Loretta Guarino Reid, DEC Ultrix Engineering Group
  89. X *        Convert to X11
  90. X * 1.2 -- Gumby cursor added (This was a major revision).
  91. X */
  92. X
  93. X#ifndef lint
  94. Xstatic char *sccsid = "@(#)StoreCursors.c    3.8    1/24/86";
  95. X#endif
  96. X
  97. X#include "awm.h"
  98. X#include "X11/cursorfont.h"
  99. X
  100. X/*
  101. X * Store all the cursors into global variables.
  102. X */
  103. XStoreCursors()
  104. X{
  105. X    Entry("StoreCursors")
  106. X
  107. X    /*
  108. X     * Main awm cursor and movement cursor.
  109. X     */
  110. X    ArrowCrossCursor = XCreateFontCursor(dpy, XC_fleur);
  111. X    if (ArrowCrossCursor == FAILURE) {
  112. X    Error("StoreCursors -> Unable to store ArrowCrossCursor.");
  113. X    }
  114. X
  115. X    /*
  116. X     * Text cursor used in icons.
  117. X     */
  118. X    TextCursor = XCreateFontCursor(dpy, XC_xterm);    
  119. X    if (TextCursor == FAILURE) {
  120. X    Error("StoreCursors -> Unable to store TextCursor.");
  121. X    }
  122. X
  123. X    /*
  124. X     * Icon cursor used to iconify windows.
  125. X     */
  126. X    IconCursor = XCreateFontCursor(dpy, XC_icon);    
  127. X    if (IconCursor == FAILURE) {
  128. X    Error("StoreCursors -> Unable to store IconCursor.");
  129. X    }
  130. X
  131. X    /*
  132. X     * Left button main cursor.
  133. X     */
  134. X    LeftButtonCursor = XCreateFontCursor(dpy, XC_leftbutton);    
  135. X    if (LeftButtonCursor == FAILURE) {
  136. X    Error("StoreCursors -> Unable to store LeftButtonCursor.");
  137. X    }
  138. X
  139. X    /*
  140. X     * Middle button main cursor.
  141. X     */
  142. X    MiddleButtonCursor = XCreateFontCursor(dpy, XC_middlebutton);    
  143. X    if (MiddleButtonCursor == FAILURE) {
  144. X    Error("StoreCursors -> Unable to store MiddleButtonCursor.");
  145. X    }
  146. X
  147. X    /*
  148. X     * Right button main cursor.
  149. X     */
  150. X    RightButtonCursor = XCreateFontCursor(dpy, XC_rightbutton);    
  151. X    if (RightButtonCursor == FAILURE) {
  152. X    Error("StoreCursors -> Unable to store RightButtonCursor.");
  153. X    }
  154. X
  155. X    /*
  156. X     * Targer cursor used to identify a window for an action.
  157. X     */
  158. X    TargetCursor = XCreateFontCursor(dpy, XC_circle);    
  159. X    if (TargetCursor == FAILURE) {
  160. X    Error("StoreCursors -> Unable to store TargetCursor.");
  161. X    }
  162. X    /*
  163. X     * Gumby cursor used in icons if icon is not a typein icon
  164. X     * (otherwise use textcursor
  165. X     */
  166. X    GumbyCursor = XCreateFontCursor(dpy, XC_gumby);    
  167. X    if (GumbyCursor == FAILURE) {
  168. X    Error("StoreCursors -> Unable to store GumbyCursor.");
  169. X    }
  170. X    Leave(0)
  171. X}
  172. X
  173. END_OF_FILE
  174. if test 4232 -ne `wc -c <'Cursors.c'`; then
  175.     echo shar: \"'Cursors.c'\" unpacked with wrong size!
  176. fi
  177. # end of 'Cursors.c'
  178. fi
  179. if test -f 'Icons.c' -a "${1}" != "-c" ; then 
  180.   echo shar: Will not clobber existing file \"'Icons.c'\"
  181. else
  182. echo shar: Extracting \"'Icons.c'\" \(14575 characters\)
  183. sed "s/^X//" >'Icons.c' <<'END_OF_FILE'
  184. X
  185. X
  186. X
  187. X#ifndef lint
  188. Xstatic char *rcsid_Icons_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/Icons.c,v 1.2 89/02/07 20:05:21 jkh Exp $";
  189. X#endif  lint
  190. X
  191. X#include "X11/copyright.h"
  192. X/*
  193. X *
  194. X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  195. X *
  196. X * Copyright 1987 by Jordan Hubbard.
  197. X *
  198. X *
  199. X *                         All Rights Reserved
  200. X *
  201. X * Permission to use, copy, modify, and distribute this software and its
  202. X * documentation for any purpose and without fee is hereby granted,
  203. X * provided that the above copyright notice appear in all copies and that
  204. X * both that copyright notice and this permission notice appear in
  205. X * supporting documentation, and that the name of Ardent Computer
  206. X * Corporation or Jordan Hubbard not be used in advertising or publicity
  207. X * pertaining to distribution of the software without specific, written
  208. X * prior permission.
  209. X *
  210. X */
  211. X
  212. X/*
  213. X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
  214. X *
  215. X *                         All Rights Reserved
  216. X *
  217. X * Permission to use, copy, modify, and distribute this software and its
  218. X * documentation for any purpose and without fee is hereby granted,
  219. X * provided that the above copyright notice appear in all copies and that
  220. X * both that copyright notice and this permission notice appear in
  221. X * supporting documentation, and that the name of Digital Equipment
  222. X * Corporation not be used in advertising or publicity pertaining to
  223. X * distribution of the software without specific, written prior permission.
  224. X *
  225. X *
  226. X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  227. X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  228. X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  229. X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  230. X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  231. X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  232. X * SOFTWARE.
  233. X */
  234. X
  235. X
  236. X/*
  237. X * MODIFICATION HISTORY
  238. X *
  239. X * 000 -- L. Guarino Reid, DEC Ultrix Engineering Group
  240. X * 001 -- Jordan Hubbard, Ardent Computer
  241. X *  Many modifications for titled windows.
  242. X * 1.2 -- Jordan Hubbard, Ardent Computer.
  243. X * vPad and hPad usage corrected (Chris Thewalt fix).
  244. X * Clipping now set on right GC. 
  245. X * 1.3 -- Changed the way icon button events are handled.
  246. X * 1.4 -- Isaac J. Salzman, RAND Corp.
  247. X * reworked the way icons are handled - if IconsLabels is set, icons
  248. X * with pixmaps are labled at bottom & icons w/o pixmaps use a default
  249. X * pixmap w/a label instead of just a solid bg tile (i.e. twm style),
  250. X * otherwise old uwm style icons are used (typin and all).
  251. X * 1.5 -- Modified Isaac's changes to allow wm_option.icon.labels to
  252. X * work. This allows individual clients/classes to determine their
  253. X * icon style.  -jkh
  254. X */
  255. X#include "awm.h"
  256. X#include "X11/Xutil.h"
  257. X
  258. Xextern XContext AwmContext;
  259. X     extern void Warning();
  260. X
  261. X/* the client should pass us a bitmap (single-plane pixmap with background=0
  262. X * and foreground = 1).  It is our responsibility to convert it to a pixmap
  263. X * of the appropriate depth for a window tile and also color it with the
  264. X * appropriate background and foreground pixels.
  265. X *
  266. X * we'll use the (global) IconGC for the fore/background pixels.
  267. X */
  268. X
  269. Xstatic Pixmap MakePixmapFromBitmap( bitmap, clipmask, width_return, height_return )
  270. XPixmap bitmap, clipmask;
  271. Xunsigned int *width_return, *height_return;
  272. X{
  273. X     Pixmap tile;
  274. X     Window junkW;
  275. X     int junk;
  276. X     unsigned int width, height;
  277. X     GC iGC;
  278. X     XGCValues gcv;
  279. X     
  280. X     Entry("MakePixmapFromBitmap")
  281. X      
  282. X     if (!XGetGeometry( dpy, bitmap, &junkW, &junk, &junk,
  283. X               &width, &height, &junk, &junk )) {
  284. X      Warning( "client passed invalid pixmap for icon." );
  285. X      Leave( NULL )
  286. X     }
  287. X     tile = XCreatePixmap( dpy, RootWindow(dpy, scr), width, height,
  288. X              (unsigned) DefaultDepth(dpy, scr) );
  289. X     gcv.foreground = ITextForeground;
  290. X     gcv.background = ITextBackground;
  291. X     iGC = XCreateGC(dpy, RootWindow(dpy, scr), (GCForeground | GCBackground),
  292. X             &gcv);
  293. X     if (clipmask)
  294. X      XSetClipMask(dpy, iGC, clipmask);
  295. X     XCopyPlane(dpy, bitmap, tile, iGC, 0, 0, width, height, 0, 0, 
  296. X        (unsigned long) 1 );
  297. X     XFreeGC(dpy, iGC);
  298. X     if (width_return)
  299. X      *width_return = width;
  300. X     if (height_return)
  301. X      *height_return = height;
  302. X     Leave(tile)
  303. X}
  304. X
  305. Xchar *GetIconName(window)
  306. XWindow window;
  307. X{
  308. X     unsigned char *name;
  309. X     Status status;
  310. X     unsigned long len, after;
  311. X     Atom a_type;
  312. X     int a_form;
  313. X     
  314. X     Entry("GetIconName")
  315. X     
  316. X     status = XGetWindowProperty(dpy, window, XA_WM_ICON_NAME, 0L, 256L,
  317. X                 False, XA_STRING, &a_type, &a_form, &len, &after,
  318. X                 &name);
  319. X     
  320. X     if (status != Success) {
  321. X      status = XGetWindowProperty(dpy, window, XA_WM_NAME, 0L, NAME_LEN,
  322. X                      False, XA_STRING, &a_type, &a_form, &len,
  323. X                      &after, &name);
  324. X      if (status != Success)
  325. X           Leave( DEF_NAME ) /* use default name */
  326. X     }
  327. X     if (a_form == 0)    /* we have no bananas */
  328. X      Leave((char *)NULL)
  329. X     if (a_form != 8) {
  330. X      Warning("Window has icon_name in wrong format");
  331. X      if (name)
  332. X           free(name);
  333. X      Leave((char *)NULL)
  334. X     }
  335. X     if (len > NAME_LEN) {
  336. X      Warning("Window has icon_name greater than maximum length");
  337. X      len = NAME_LEN;
  338. X     }
  339. X     if (!len)
  340. X      Leave((char *)NULL)
  341. X     name[len] = 0;
  342. X     Leave((char *) name)
  343. X}
  344. X
  345. XBoolean IsIcon(icon, win)
  346. XWindow icon;
  347. XWindow *win;
  348. X{
  349. X     AwmInfoPtr awi;
  350. X
  351. X     Entry("IsIcon")
  352. X
  353. X     if (win)
  354. X      *win = 0;
  355. X     awi = GetAwmInfo(icon);
  356. X     if (!awi)
  357. X      Leave(FALSE)
  358. X     if (awi->icon == icon) {
  359. X      if (win)
  360. X           *win = awi->client;
  361. X      Leave(TRUE)
  362. X     }
  363. X     else if (awi->client == icon || awi->frame == icon) {
  364. X      if (win)
  365. X           *win = awi->icon;
  366. X      Leave(FALSE)
  367. X     }
  368. X     Leave(FALSE)
  369. X}
  370. X
  371. XRemoveIcon(window)
  372. XWindow window;
  373. X{
  374. X     AwmInfoPtr awi;
  375. X
  376. X     Entry("RemoveIcon")
  377. X     
  378. X     if ((awi = GetAwmInfo(window)) != NULL) {
  379. X      XDeleteContext(dpy, awi->icon, AwmContext);
  380. X      if (awi->own) {
  381. X           XDestroyWindow(dpy, awi->icon);
  382. X           if ((awi->iconPixmap != IBackPixmap) && 
  383. X           (awi->iconPixmap != IDefPixmap))
  384. X           XFreePixmap(dpy, awi->iconPixmap);
  385. X      }
  386. X      awi->icon = (Drawable)NULL;
  387. X      awi->state ^= ST_ICON;
  388. X      awi->state |= ST_WINDOW;
  389. X#ifdef WMSTATE
  390. X      awi->wm_state.icon=0;
  391. X      awi->wm_state.state=NormalState;
  392. X      XChangeProperty(dpy,awi->client,wm_state_atom,wm_state_atom,32,
  393. X              PropModeReplace,(char *) &awi->wm_state,2);
  394. X#endif /* WMSTATE */
  395. X     }
  396. X     Leave_void
  397. X}
  398. X
  399. XGetDefaultSize(window, icon_w, icon_h)
  400. XWindow window;
  401. Xint *icon_w, *icon_h;
  402. X{
  403. X     char *name;                /* Event window name. */
  404. X
  405. X     Entry("GetDefaultSize")
  406. X
  407. X     /*
  408. X      * Determine the size of the icon window.
  409. X      */ 
  410. X     name = GetIconName(window);
  411. X     *icon_h = IFontInfo->ascent + IFontInfo->descent;
  412. X     if (name) {
  413. X      *icon_w = XTextWidth(IFontInfo, name, strlen(name));
  414. X      if (*icon_w == 0)
  415. X           *icon_w = *icon_h;
  416. X     }
  417. X     else 
  418. X      *icon_w = *icon_h = 0; /* set to zilch if bogus name! */
  419. X     Leave_void
  420. X}
  421. X
  422. XWindow MakeIcon(window, x, y, mousePositioned)
  423. XWindow window;                          /* associated window. */
  424. Xint x, y;                               /* Event mouse position. */
  425. XBoolean mousePositioned;
  426. X{
  427. X     int icon_x, icon_y;        /* Icon U. L. X and Y coordinates. */
  428. X     unsigned int icon_w, icon_h;    /* Icon width and height. */
  429. X     unsigned int icon_bdr;        /* Icon border width. */
  430. X     long mask;                /* Icon event mask */
  431. X     XSetWindowAttributes iconValues;    /* for icon window creation */
  432. X     unsigned long iconValues_mask;    /* for above */
  433. X     XWMHints *wmhints;            /* see if icon position provided */
  434. X     XWMHints *XGetWMHints();
  435. X     Pixmap clip = 0;
  436. X     Window AddIcon();
  437. X     AwmInfoPtr awi;
  438. X     int junk;
  439. X
  440. X     Entry("MakeIcon")
  441. X
  442. X     awi = GetAwmInfo(window);
  443. X
  444. X     if (awi->attrs & AT_ICONLABEL) {    /* check for iconLables - twm style */
  445. X      iconValues.background_pixmap = IDefPixmap;
  446. X      mask = StructureNotifyMask;
  447. X     }
  448. X     else {                    /* uwm style */
  449. X      iconValues.background_pixmap = IBackPixmap;
  450. X      mask = (ExposureMask | StructureNotifyMask | KeyPressMask);
  451. X     }
  452. X
  453. X     /*
  454. X      * Process window manager hints.
  455. X      */ 
  456. X     if (wmhints = XGetWMHints(dpy, window)) {
  457. X      if (wmhints->flags & IconWindowHint)
  458. X           Leave(AddIcon(window, wmhints->icon_window, FALSE,
  459. X                 (StructureNotifyMask), (Pixmap)NULL));
  460. X
  461. X       if (wmhints->flags & IconPixmapHint) {
  462. X        if (wmhints->flags & IconMaskHint)
  463. X             clip = wmhints->icon_mask;
  464. X        iconValues.background_pixmap =
  465. X             MakePixmapFromBitmap(wmhints->icon_pixmap, clip,
  466. X                      &icon_w, &icon_h );
  467. X        if (iconValues.background_pixmap)
  468. X             mask = (StructureNotifyMask);
  469. X         else {
  470. X              iconValues.background_pixmap = IBackPixmap;
  471. X              wmhints->flags &= ~IconPixmapHint;
  472. X         }
  473. X       }
  474. X     }
  475. X     
  476. X     /*
  477. X      * we now have a pixmap of some sort - either a background
  478. X      *  tile or an actual image - get the dimensions...
  479. X      */
  480. X
  481. X     if (!XGetGeometry(dpy, iconValues.background_pixmap,
  482. X               &junk, &junk, &junk,
  483. X               &icon_w, &icon_h, &junk, &junk )) {
  484. X      Warning( "can't get geom of pixmap in MakeIcon" );
  485. X      Leave( NULL );
  486. X     }
  487. X     
  488. X     if (awi->attrs & AT_ICONLABEL) {
  489. X      char *s;
  490. X      Pixmap p;
  491. X      unsigned int nw, nh;
  492. X      int tw, th, hoff, voff;
  493. X       
  494. X       if (s = GetIconName(window)) {
  495. X        nw = icon_w;
  496. X        nh = icon_h;
  497. X
  498. X        /* find out dimensions of text, add padding */
  499. X        tw = XTextWidth(IFontInfo, s, strlen(s)) + HIconPad;
  500. X        th = IFontInfo->ascent + IFontInfo->descent + VIconPad;
  501. X        
  502. X        
  503. X        /* calculate the size including the icon label */
  504. X        if (nw < tw)    /* width >= text width */
  505. X             nw = tw;
  506. X        
  507. X        /* always tack on extra for the label height */
  508. X        nh += th;
  509. X        
  510. X        /* now that we have dimensions, create the pixmap
  511. X           we want to eventually use as the icon window
  512. X           */
  513. X        
  514. X        if (!(p = XCreatePixmap(dpy, RootWindow(dpy, scr), nw, nh,
  515. X                    (unsigned) DefaultDepth(dpy, scr)))) {
  516. X             Warning("can't create pixmap in MakeIcon.");
  517. X             Leave( NULL )
  518. X        }
  519. X
  520. X        /* calculate horizontal offset of pixmap (center it!) */
  521. X        if (hoff = (nw - icon_w))
  522. X             hoff = (hoff+1)/2;
  523. X        
  524. X        /* if the label goes at the top, push the thing to the bottom
  525. X         * otherwise leave it at the top
  526. X             */
  527. X        
  528. X        voff = ILabelTop ? (th - (VIconPad+1)/2) : (VIconPad+1)/2;
  529. X        
  530. X        XCopyArea(dpy, iconValues.background_pixmap, p,
  531. X              IconGC, 0, 0, icon_w, icon_h, 
  532. X              hoff, voff);
  533. X        
  534. X        /* now that we have a centered pixmap draw
  535. X         * some text on it....
  536. X         */
  537. X        
  538. X        if (hoff = (nw - tw))
  539. X             hoff = (hoff+1)/2;
  540. X        else
  541. X             hoff = (HIconPad ? (HIconPad+1)/2 : 1);
  542. X        
  543. X        /* see if string goes to top or bottom */
  544. X        if (ILabelTop)
  545. X             voff = th - (IFontInfo->descent-((VIconPad+1)/2));
  546. X        else
  547. X             voff = nh-(IFontInfo->descent+((VIconPad+1)/2));
  548. X        
  549. X        XDrawImageString(dpy, p, IconGC, hoff, voff, s, strlen(s));
  550. X        
  551. X        /*
  552. X         * Now free up original pixmap and replace
  553. X         * with this new one.
  554. X         */
  555. X        
  556. X        icon_h = nh;
  557. X        icon_w = nw;
  558. X        
  559. X        if ((iconValues.background_pixmap != IBackPixmap) &&
  560. X            (iconValues.background_pixmap != IDefPixmap))
  561. X             XFreePixmap(dpy, iconValues.background_pixmap);
  562. X        iconValues.background_pixmap = p;
  563. X       }
  564. X     }         
  565. X     else {             /* do it the old way.... */
  566. X      int h, w;
  567. X      
  568. X      if (!wmhints || !(wmhints->flags & IconPixmapHint)) {
  569. X           GetDefaultSize(window, &w, &h);
  570. X            
  571. X           if ((w==0) || (h==0)) { /* no label, use IDefPixmap */
  572. X            iconValues.background_pixmap = IDefPixmap;
  573. X             
  574. X            /* get geom of ipixmap */
  575. X            if (!XGetGeometry(dpy, iconValues.background_pixmap,
  576. X                      &junk, &junk, &junk,
  577. X                      &icon_w, &icon_h, &junk, &junk)) {
  578. X             Warning("can't get geom of pixmap in MakeIcon");
  579. X             Leave(NULL)
  580. X            }
  581. X           }
  582. X           else { /* use small label icon + some padding */
  583. X            icon_h = h+VIconPad;
  584. X            icon_w = w+HIconPad;
  585. X           }
  586. X      }
  587. X     }
  588. X     /*
  589. X      * Set the icon border attributes.
  590. X      */ 
  591. X     if (!wmhints || !(wmhints->flags & IconWindowHint)) {
  592. X      icon_bdr = IBorderWidth;
  593. X      iconValues.border_pixel = IBorder;
  594. X     }
  595. X     /*
  596. X      * Determine icon position....
  597. X      */
  598. X     if (wmhints && (wmhints->flags & IconPositionHint)) {
  599. X      icon_x = wmhints->icon_x;
  600. X      icon_y = wmhints->icon_y;
  601. X     } else {
  602. X      if (mousePositioned) {
  603. X           /*
  604. X        * Determine the coordinates of the icon window;
  605. X        * normalize so that we don't lose the icon off the
  606. X        * edge of the screen.
  607. X        */
  608. X           icon_x = x - (icon_w >> 1) + 1;
  609. X           if (icon_x < 0) icon_x = 0;
  610. X           icon_y = y - (icon_h >> 1) + 1;
  611. X           if (icon_y < 0) icon_y = 0;
  612. X           if ((icon_x - 1 + icon_w + (icon_bdr << 1)) > ScreenWidth) {
  613. X            icon_x = ScreenWidth - icon_w - (icon_bdr << 1) + 1;
  614. X           }
  615. X           if ((icon_y - 1 + icon_h + (icon_bdr << 1)) > ScreenHeight) {
  616. X            icon_y = ScreenHeight - icon_h - (icon_bdr << 1) + 1;
  617. X           }
  618. X      }
  619. X      else {
  620. X           icon_x = x + (icon_w >> 1);
  621. X           icon_y = y + (icon_y >> 1);
  622. X      }
  623. X      
  624. X     }
  625. X
  626. X     /*
  627. X      * Create the icon window.
  628. X      */
  629. X     iconValues_mask = CWBorderPixel | CWBackPixmap;
  630. X     /*
  631. X      * Here we assume that if they want save unders, they'll also want
  632. X      * backing store on the icons. Perhaps a dangerous assumption, but
  633. X      * one we have to make at this point.
  634. X      */
  635. X     if (SaveUnder) {
  636. X      iconValues.backing_store = WhenMapped;
  637. X      iconValues_mask |= CWBackingStore;
  638. X     }
  639. X     Leave(AddIcon(window,
  640. X           XCreateWindow(
  641. X                 dpy, RootWindow(dpy, scr),
  642. X                 icon_x, icon_y,
  643. X                 icon_w, icon_h,
  644. X                 icon_bdr, 0, CopyFromParent, CopyFromParent,
  645. X                 iconValues_mask, &iconValues),
  646. X           TRUE, mask, iconValues.background_pixmap))
  647. X}
  648. X
  649. XWindow AddIcon(window, icon, own, mask, background)
  650. XWindow window, icon;
  651. XBoolean own;
  652. Xlong mask;
  653. XPixmap background;
  654. X{
  655. X     AwmInfoPtr awi;
  656. X
  657. X     Entry("AddIcon")
  658. X
  659. X     if (icon == NULL)
  660. X      Leave(NULL)
  661. X     /*
  662. X      * Use the text cursor whenever the mouse is in the icon window, if
  663. X      * it's a typein icon, otherwise use gumby....
  664. X      */
  665. X
  666. X     if (background == IBackPixmap)
  667. X     XDefineCursor(dpy, icon, TextCursor);
  668. X     else
  669. X     XDefineCursor(dpy, icon, GumbyCursor);
  670. X     
  671. X     /*
  672. X      * Select "key pressed", "window exposure" and "unmap window"
  673. X      * events for the icon window.
  674. X      */
  675. X     XSelectInput(dpy, icon, mask | ButtonPressMask | ButtonReleaseMask);
  676. X
  677. X     awi = GetAwmInfo(window);
  678. X     awi->icon = icon;
  679. X     awi->own = own;
  680. X     awi->iconPixmap = background;
  681. X#ifdef WMSTATE
  682. X     awi->wm_state.icon=icon;
  683. X     XChangeProperty(dpy,awi->client,wm_state_atom,wm_state_atom,32,
  684. X             PropModeReplace,(char *) &awi->wm_state,2);
  685. X#endif /* WMSTATE */
  686. X     XSaveContext(dpy, icon, AwmContext, (caddr_t) awi);
  687. X     Leave(icon)
  688. X}
  689. END_OF_FILE
  690. if test 14575 -ne `wc -c <'Icons.c'`; then
  691.     echo shar: \"'Icons.c'\" unpacked with wrong size!
  692. fi
  693. # end of 'Icons.c'
  694. fi
  695. if test -f 'Makefile.rtl' -a "${1}" != "-c" ; then 
  696.   echo shar: Will not clobber existing file \"'Makefile.rtl'\"
  697. else
  698. echo shar: Extracting \"'Makefile.rtl'\" \(10660 characters\)
  699. sed "s/^X//" >'Makefile.rtl' <<'END_OF_FILE'
  700. X# makefile generated by mkold
  701. X
  702. XXDIR = /usr/src/X.V11R2
  703. X
  704. XCOM.00 = $(XDIR)/lib
  705. XDIR.00 = $(COM.00)/oldX
  706. XDIR.01 = $(COM.00)/X
  707. X
  708. XNEATENOBJS =  \
  709. X    check_can_mod.o check_grow.o check_shrink.o \
  710. X    commit_op.o goal.o gravity.o mem.o state.o \
  711. X    tilwin_close.o tilwin_create.o tilwin_desk.o \
  712. X    tilwin_dump.o tilwin_init.o tilwin_list.o tilwin_misc.o \
  713. X    tilwin_open.o tilwin_resat.o tilwin_resize.o \
  714. X    tilwin_set.o tilwin_tmp.o tilwin_undo.o trial_grow.o \
  715. X    trial_place.o trial_satisfy.o trial_slide.o \
  716. X    tilwin_slide.o trial_edge_sweep.o win.o tilwin_thread.o \
  717. X    init_tws.o pieces_enum.o pieces_merge.o pieces_split.o \
  718. X    pieces_update.o tile_create.o tile_delete.o \
  719. X    tile_enlarge.o tile_find.o tile_nbrs.o tile_panic.o \
  720. X    tile_shrink.o tileopts.o userglobals.o neaten.o
  721. X
  722. Xneaten.a: $(NEATENOBJS)
  723. X    ar qcv neaten.a $(NEATENOBJS)
  724. X    ranlib neaten.a
  725. X
  726. Xcheck_can_mod.o : check_can_mod.c tilwin.extern.h state.extern.h \
  727. X        state.h tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
  728. X        std_defs.h tilwin.define.h tileopts.h copyright.h
  729. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c check_can_mod.c
  730. X
  731. Xcheck_grow.o : check_grow.c win.extern.h tile.extern.h tile.h \
  732. X        basetype.h std_defs.h state.extern.h state.h \
  733. X        tilwin.intern.h tilwin.h tilwinopts.h tilwin.extern.h \
  734. X        tilwin.define.h tileopts.h copyright.h
  735. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c check_grow.c
  736. X
  737. Xcheck_shrink.o : check_shrink.c goal.extern.h tilwin.extern.h \
  738. X        state.extern.h state.h tilwin.intern.h tilwin.h \
  739. X        tilwinopts.h basetype.h std_defs.h tilwin.define.h \
  740. X        tileopts.h
  741. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c check_shrink.c
  742. X
  743. Xcommit_op.o : commit_op.c win.extern.h tile.extern.h tile.h basetype.h \
  744. X        std_defs.h state.extern.h state.h tilwin.intern.h \
  745. X        tilwin.h tilwinopts.h tilwin.define.h tileopts.h
  746. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c commit_op.c
  747. X
  748. Xgoal.o : goal.c tilwin.define.h tileopts.h tilwin.intern.h tilwin.h \
  749. X        tilwinopts.h basetype.h std_defs.h copyright.h
  750. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c goal.c
  751. X
  752. Xgravity.o : gravity.c tilwin.extern.h state.extern.h state.h \
  753. X        tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
  754. X        std_defs.h tilwin.define.h tileopts.h copyright.h
  755. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c gravity.c
  756. X
  757. Xmem.o : mem.c tile.h basetype.h std_defs.h tilwin.intern.h tilwin.h \
  758. X        tilwinopts.h copyright.h
  759. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c mem.c
  760. X
  761. Xstate.o : state.c tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
  762. X        std_defs.h state.h copyright.h
  763. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c state.c
  764. X
  765. Xtilwin_close.o : tilwin_close.c state.extern.h state.h tilwin.intern.h \
  766. X        tilwin.h tilwinopts.h basetype.h std_defs.h win.extern.h \
  767. X        tilwin.define.h tileopts.h copyright.h
  768. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_close.c
  769. X
  770. Xtilwin_create.o : tilwin_create.c mem.extern.h state.extern.h state.h \
  771. X        tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
  772. X        std_defs.h tilwin.define.h tileopts.h copyright.h
  773. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_create.c
  774. X
  775. Xtilwin_desk.o : tilwin_desk.c gravity.extern.h basetype.h std_defs.h \
  776. X        tile.extern.h tile.h tilwin.extern.h state.extern.h \
  777. X        state.h tilwin.intern.h tilwin.h tilwinopts.h \
  778. X        copyright.h
  779. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_desk.c
  780. X
  781. Xtilwin_dump.o : tilwin_dump.c win.extern.h tilwin.extern.h \
  782. X        state.extern.h state.h tilwin.intern.h tilwin.h \
  783. X        tilwinopts.h basetype.h std_defs.h tilwin.define.h \
  784. X        tileopts.h tile.extern.h tile.h tile.define.h \
  785. X        tile.intern.h copyright.h
  786. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_dump.c
  787. X
  788. Xtilwin_init.o : tilwin_init.c tile.intern.h tile.h basetype.h \
  789. X        std_defs.h tilwin.intern.h tilwin.h tilwinopts.h \
  790. X        copyright.h
  791. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_init.c
  792. X
  793. Xtilwin_list.o : tilwin_list.c state.extern.h state.h tilwin.intern.h \
  794. X        tilwin.h tilwinopts.h basetype.h std_defs.h \
  795. X        tilwin.define.h tileopts.h copyright.h
  796. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_list.c
  797. X
  798. Xtilwin_misc.o : tilwin_misc.c win.extern.h tile.extern.h tile.h \
  799. X        basetype.h std_defs.h tile.define.h tile.intern.h \
  800. X        state.extern.h state.h tilwin.intern.h tilwin.h \
  801. X        tilwinopts.h tilwin.define.h tileopts.h copyright.h
  802. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_misc.c
  803. X
  804. Xtilwin_open.o : tilwin_open.c win.extern.h gravity.extern.h basetype.h \
  805. X        std_defs.h commit.extern.h trial.extern.h trial.h \
  806. X        state.extern.h state.h tilwin.intern.h tilwin.h \
  807. X        tilwinopts.h tilwin.define.h tileopts.h copyright.h
  808. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_open.c
  809. X
  810. Xtilwin_resat.o : tilwin_resat.c win.extern.h commit.extern.h \
  811. X        trial.extern.h trial.h state.extern.h state.h \
  812. X        tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
  813. X        std_defs.h tilwin.define.h tileopts.h copyright.h
  814. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_resat.c
  815. X
  816. Xtilwin_resize.o : tilwin_resize.c gravity.extern.h basetype.h \
  817. X        std_defs.h win.extern.h commit.extern.h trial.extern.h \
  818. X        trial.h state.extern.h state.h tilwin.intern.h tilwin.h \
  819. X        tilwinopts.h tilwin.define.h tileopts.h copyright.h
  820. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_resize.c
  821. X
  822. Xtilwin_set.o : tilwin_set.c trial.extern.h trial.h state.extern.h \
  823. X        state.h tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
  824. X        std_defs.h tilwin.define.h tileopts.h copyright.h
  825. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_set.c
  826. X
  827. Xtilwin_tmp.o : tilwin_tmp.c trial.h state.extern.h state.h \
  828. X        tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
  829. X        std_defs.h trial.extern.h tilwin.define.h tileopts.h \
  830. X        copyright.h
  831. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_tmp.c
  832. X
  833. Xtilwin_undo.o : tilwin_undo.c win.extern.h state.extern.h state.h \
  834. X        tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
  835. X        std_defs.h tilwin.define.h tileopts.h copyright.h
  836. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_undo.c
  837. X
  838. Xtrial_grow.o : trial_grow.c check.extern.h gravity.extern.h basetype.h \
  839. X        std_defs.h tilwin.extern.h state.extern.h state.h \
  840. X        tilwin.intern.h tilwin.h tilwinopts.h tilwin.define.h \
  841. X        tileopts.h copyright.h
  842. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c trial_grow.c
  843. X
  844. Xtrial_place.o : trial_place.c check.extern.h gravity.extern.h \
  845. X        basetype.h std_defs.h tilwin.extern.h state.extern.h \
  846. X        state.h tilwin.intern.h tilwin.h tilwinopts.h \
  847. X        tilwin.define.h tileopts.h copyright.h
  848. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c trial_place.c
  849. X
  850. Xtrial_satisfy.o : trial_satisfy.c check.extern.h gravity.extern.h \
  851. X        basetype.h std_defs.h tilwin.extern.h state.extern.h \
  852. X        state.h tilwin.intern.h tilwin.h tilwinopts.h \
  853. X        tilwin.define.h tileopts.h copyright.h
  854. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c trial_satisfy.c
  855. X
  856. Xtrial_slide.o : trial_slide.c trial.extern.h trial.h tilwin.extern.h \
  857. X        state.extern.h state.h tilwin.intern.h tilwin.h \
  858. X        tilwinopts.h basetype.h std_defs.h tilwin.define.h \
  859. X        tileopts.h copyright.h
  860. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c trial_slide.c
  861. X
  862. Xtilwin_slide.o : tilwin_slide.c trial.extern.h trial.h tilwin.extern.h \
  863. X        state.extern.h state.h tilwin.intern.h tilwin.h \
  864. X        tilwinopts.h basetype.h std_defs.h tilwin.define.h \
  865. X        tileopts.h copyright.h
  866. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_slide.c
  867. X
  868. Xtrial_edge_sweep.o : trial_edge_sweep.c tilwin.extern.h state.extern.h \
  869. X        state.h tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
  870. X        std_defs.h tile.extern.h tile.h tile.define.h \
  871. X        tile.intern.h copyright.h
  872. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c trial_edge_sweep.c
  873. X
  874. Xwin.o : win.c gravity.extern.h basetype.h std_defs.h state.extern.h \
  875. X        state.h tilwin.intern.h tilwin.h tilwinopts.h \
  876. X        tile.define.h tile.intern.h tile.h tile.extern.h \
  877. X        tilwin.define.h tileopts.h copyright.h
  878. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c win.c
  879. X
  880. Xtilwin_thread.o : tilwin_thread.c state.extern.h state.h \
  881. X        tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
  882. X        std_defs.h tilwin.define.h tileopts.h copyright.h
  883. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tilwin_thread.c
  884. X
  885. Xinit_tws.o : init_tws.c tile-list.h tile.define.h tile.intern.h tile.h \
  886. X        basetype.h std_defs.h copyright.h
  887. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c init_tws.c
  888. X
  889. Xpieces_enum.o : pieces_enum.c tile.extern.h tile.h basetype.h \
  890. X        std_defs.h tile-list.h tile.define.h tile.intern.h \
  891. X        copyright.h
  892. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c pieces_enum.c
  893. X
  894. Xpieces_merge.o : pieces_merge.c tile-list.h tile.define.h tile.intern.h \
  895. X        tile.h basetype.h std_defs.h copyright.h
  896. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c pieces_merge.c
  897. X
  898. Xpieces_split.o : pieces_split.c tile.extern.h tile.h basetype.h \
  899. X        std_defs.h tile-list.h tile.define.h tile.intern.h \
  900. X        copyright.h
  901. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c pieces_split.c
  902. X
  903. Xpieces_update.o : pieces_update.c tile-list.h tile.define.h \
  904. X        tile.intern.h tile.h basetype.h std_defs.h copyright.h
  905. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c pieces_update.c
  906. X
  907. Xtile_create.o : tile_create.c tile.extern.h tile.h basetype.h \
  908. X        std_defs.h tile.define.h tile.intern.h copyright.h
  909. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tile_create.c
  910. X
  911. Xtile_delete.o : tile_delete.c tile.extern.h tile.h basetype.h \
  912. X        std_defs.h tile-list.h tile.define.h tile.intern.h \
  913. X        copyright.h
  914. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tile_delete.c
  915. X
  916. Xtile_enlarge.o : tile_enlarge.c tile.extern.h tile.h basetype.h \
  917. X        std_defs.h tile.define.h tile.intern.h copyright.h
  918. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tile_enlarge.c
  919. X
  920. Xtile_find.o : tile_find.c tilwin.extern.h state.extern.h state.h \
  921. X        tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
  922. X        std_defs.h tile.define.h tile.intern.h tile.h \
  923. X        copyright.h
  924. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tile_find.c
  925. X
  926. Xtile_nbrs.o : tile_nbrs.c tile-list.h tile.extern.h tile.h basetype.h \
  927. X        std_defs.h tile.define.h tile.intern.h
  928. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tile_nbrs.c
  929. X
  930. Xtile_panic.o : tile_panic.c copyright.h
  931. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tile_panic.c
  932. X
  933. Xtile_shrink.o : tile_shrink.c tile.define.h tile.intern.h tile.h \
  934. X        basetype.h std_defs.h copyright.h
  935. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tile_shrink.c
  936. X
  937. Xtileopts.o : tileopts.c tileopts.h basetype.h std_defs.h copyright.h
  938. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c tileopts.c
  939. X
  940. Xuserglobals.o : userglobals.c explicitopts.h uservals.h useropts.h \
  941. X        basetype.h std_defs.h copyright.h
  942. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c userglobals.c
  943. X
  944. Xneaten.o : neaten.c neaten.define.h tilwin.define.h tileopts.h \
  945. X        tilwin.intern.h tilwin.h tilwinopts.h basetype.h \
  946. X        std_defs.h userwin.define.h tilwin.extern.h \
  947. X        state.extern.h state.h userglobals.define.h userwin.h \
  948. X        explicitwinopts.h userwinopts.h 
  949. X     $(CC) $(CFLAGS) -g -DNEATEN -DWM_DEBUG -c neaten.c
  950. END_OF_FILE
  951. if test 10660 -ne `wc -c <'Makefile.rtl'`; then
  952.     echo shar: \"'Makefile.rtl'\" unpacked with wrong size!
  953. fi
  954. # end of 'Makefile.rtl'
  955. fi
  956. if test -f 'RubberBand.c' -a "${1}" != "-c" ; then 
  957.   echo shar: Will not clobber existing file \"'RubberBand.c'\"
  958. else
  959. echo shar: Extracting \"'RubberBand.c'\" \(12196 characters\)
  960. sed "s/^X//" >'RubberBand.c' <<'END_OF_FILE'
  961. X
  962. X
  963. X
  964. X#ifndef lint
  965. Xstatic char *rcsid_RubberBand_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/RubberBand.c,v 1.2 89/02/07 21:23:46 jkh Exp $";
  966. X#endif  lint
  967. X
  968. X#include "X11/copyright.h"
  969. X/*
  970. X *
  971. X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  972. X *
  973. X * Copyright 1987 by Jordan Hubbard.
  974. X *
  975. X *
  976. X *                         All Rights Reserved
  977. X *
  978. X * Permission to use, copy, modify, and distribute this software and its
  979. X * documentation for any purpose and without fee is hereby granted,
  980. X * provided that the above copyright notice appear in all copies and that
  981. X * both that copyright notice and this permission notice appear in
  982. X * supporting documentation, and that the name of Ardent Computer
  983. X * Corporation or Jordan Hubbard not be used in advertising or publicity
  984. X * pertaining to distribution of the software without specific, written
  985. X * prior permission.
  986. X *
  987. X */
  988. X
  989. X/*
  990. X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
  991. X *
  992. X *                         All Rights Reserved
  993. X *
  994. X * Permission to use, copy, modify, and distribute this software and its
  995. X * documentation for any purpose and without fee is hereby granted,
  996. X * provided that the above copyright notice appear in all copies and that
  997. X * both that copyright notice and this permission notice appear in
  998. X * supporting documentation, and that the name of Digital Equipment
  999. X * Corporation not be used in advertising or publicity pertaining to
  1000. X * distribution of the software without specific, written prior permission.
  1001. X *
  1002. X *
  1003. X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  1004. X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  1005. X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  1006. X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  1007. X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  1008. X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  1009. X * SOFTWARE.
  1010. X */
  1011. X
  1012. X/*
  1013. X * MODIFICATION HISTORY
  1014. X *
  1015. X * 000 -- Loretta Guarino Reid, DEC Ultrix Engineering Group
  1016. X * 001 -- Ralph R. Swick, DEC/MIT Project Athena
  1017. X *      tailor to uwm; use global resources created by uwm
  1018. X */
  1019. X
  1020. X#include "awm.h"
  1021. X#include "X11/Xutil.h"
  1022. X#include "X11/cursorfont.h"
  1023. X
  1024. X#define max(a,b) ( (a) > (b) ? (a) : (b) )
  1025. X#define min(a,b) ( (a) > (b) ? (b) : (a) )
  1026. X#define abs(a) ( (a) > 0 ? (a) : -(a))
  1027. X#define makemult(a, b) ((b==1) ? (a) : (((int)((a) / (b))) * (b)) )
  1028. X
  1029. X#define DCOUNT 2
  1030. X#define PCOUNT 1 + (4 * 2 * DCOUNT)
  1031. X
  1032. X#define BW    PBorderWidth        /* pop-up window border width */
  1033. X#define IBW    PPadding        /* internal border width for pop-up */
  1034. X
  1035. XAskUser(dpy, scr, window, x, y, width, height, hints, transient)
  1036. XDisplay *dpy;
  1037. Xint scr;
  1038. XWindow window;
  1039. Xint *x, *y;
  1040. Xunsigned int *width, *height;
  1041. XXSizeHints *hints;
  1042. XWindow transient;
  1043. X{
  1044. X     Cursor ur, ul, ll, lr;          /* cursors for rubber banding    */
  1045. X     int change_cursor = FALSE;
  1046. X     int current_cursor;
  1047. X     char *text;            /* text for prompt string       */
  1048. X     int nz;                         /* count where zeros are        */
  1049. X     unsigned int popw, poph;        /* width and height of prompt window*/
  1050. X#define invertGC DrawGC
  1051. X     int x1, y1;                     /* location of mouse            */
  1052. X     int x2, y2;                     /* other corner of box          */
  1053. X     int rootx, rooty;
  1054. X     unsigned int mask;         /* for XQueryPointer          */
  1055. X     Window root, subw;        /* for XQueryPointer */
  1056. X     int xa = -1, ya = -1, xb = -1, yb = -1;
  1057. X     int xinc, yinc;
  1058. X     unsigned int minwidth, minheight;
  1059. X     unsigned int maxwidth, maxheight;
  1060. X     unsigned int defwidth, defheight;
  1061. X     int chosen = -1;
  1062. X     int stop = FALSE;
  1063. X     int changed = TRUE;
  1064. X     int doit = FALSE;
  1065. X     int dx, dy;
  1066. X     int delta;
  1067. X     int ijunk;
  1068. X     XPoint box[PCOUNT];
  1069. X     int hsize, vsize;
  1070. X     int zero = '0';                 /* zero offset for char conversion  */
  1071. X     XEvent e;                 /* someplace to put the event   */
  1072. X     unsigned int events;               /* what events we want.             */
  1073. X     Window pop, wjunk;                     /* pop up prompt window         */
  1074. X     int i;
  1075. X     char *name;
  1076. X     int width_offset, height_offset; /* to subtract if resize increments */
  1077. X     
  1078. X     Entry("AskUser")
  1079. X
  1080. X     if (transient) {
  1081. X      XGetGeometry( dpy, window, &wjunk, x, y, width, height,
  1082. X               &ijunk, &ijunk);
  1083. X      Leave_void
  1084. X     }
  1085. X     if ((hints->flags & USPosition) && (hints->flags & USSize)) {
  1086. X      *x = hints->x;
  1087. X      *y = hints->y;
  1088. X      *width = hints->width;
  1089. X      *height = hints->height;
  1090. X      Leave_void
  1091. X     }
  1092. X     if (!XFetchName(dpy, window, &name)) 
  1093. X      name = "Unnamed Window";
  1094. X     
  1095. X     ur = XCreateFontCursor(dpy, XC_ur_angle);
  1096. X     ul = XCreateFontCursor(dpy, XC_ul_angle);
  1097. X     ll = XCreateFontCursor(dpy, XC_ll_angle);
  1098. X     lr = XCreateFontCursor(dpy, XC_lr_angle);
  1099. X     current_cursor = ul;
  1100. X     
  1101. X     events = ButtonPressMask | ButtonReleaseMask;
  1102. X     
  1103. X     /* 
  1104. X      * go get the mouse as soon as you can 
  1105. X      */
  1106. X     
  1107. X     while (1) {
  1108. X      if (XGrabPointer (dpy, RootWindow(dpy, scr), FALSE, events, 
  1109. X                   GrabModeAsync, GrabModeAsync, None, ul,
  1110. X                   CurrentTime) == GrabSuccess)
  1111. X           break;
  1112. X      sleep (1);
  1113. X     }
  1114. X     nz = strlen(name);        /* compute number of characters */
  1115. X     text = (char *)malloc( nz + 11 );
  1116. X     (void) strcpy(text, name);
  1117. X     (void) strcat(text, ": 000x000");
  1118. X     nz += 9;
  1119. X     popw = XTextWidth (PFontInfo, text, nz) + 2 * IBW;
  1120. X     poph = PFontInfo->ascent+PFontInfo->descent + 2 * IBW;
  1121. X     
  1122. X     pop = XCreateSimpleWindow(dpy, RootWindow(dpy, scr), 
  1123. X                   0, 0, popw, poph, BW, PBorder, PBackground);
  1124. X     XMapWindow (dpy, pop);
  1125. X     
  1126. X     if (hints->flags & PMinSize) {
  1127. X      minwidth = hints->min_width;
  1128. X      minheight = hints->min_height;
  1129. X     } else {
  1130. X      minwidth = 0;
  1131. X      minheight = 0;
  1132. X     }
  1133. X     if (hints->flags & PMaxSize) {
  1134. X      maxwidth = max(hints->max_width, minwidth);
  1135. X      maxheight = max(hints->max_height, minheight);
  1136. X     } else {
  1137. X      maxwidth = DisplayWidth(dpy, scr);
  1138. X      maxheight = DisplayHeight(dpy, scr);
  1139. X     }
  1140. X     if (hints->flags & PResizeInc) {
  1141. X      xinc = hints->width_inc;
  1142. X      yinc = hints->height_inc;
  1143. X     } else {
  1144. X      xinc = 1;
  1145. X      yinc = 1;
  1146. X     }
  1147. X     if (hints->flags & PSize || hints->flags & USSize) {
  1148. X      defwidth = hints->width;
  1149. X      defheight = hints->height;
  1150. X     } else if (hints->flags&PMinSize) {
  1151. X      defwidth = hints->min_width;
  1152. X      defheight = hints->min_height;
  1153. X     } else if (hints->flags&PMaxSize) {
  1154. X      defwidth = hints->max_width;
  1155. X      defheight = hints->max_height;
  1156. X     } else {
  1157. X      long dummy;
  1158. X      XGetGeometry(dpy, window, &dummy, &dummy, &dummy,
  1159. X               &defwidth, &defheight, &dummy, &dummy);
  1160. X     }
  1161. X     
  1162. X     /* until there are better WM_HINTS, we'll assume that the client's
  1163. X      * minimum width and height are the appropriate offsets to subtract
  1164. X      * when resizing with an explicit resize increment.
  1165. X      */
  1166. X     if (hints->flags & PMinSize && hints->flags & PResizeInc) {
  1167. X      width_offset = hints->min_width;
  1168. X      height_offset = hints->min_height;
  1169. X     } else
  1170. X      width_offset = height_offset = 0;
  1171. X     
  1172. X     
  1173. X     XQueryPointer (dpy, RootWindow(dpy, scr), &root, &subw, 
  1174. X            &rootx, &rooty, &x1, &y1, &mask);
  1175. X     hsize = minwidth; 
  1176. X     vsize = minheight;
  1177. X     x2 = x1+hsize; 
  1178. X     y2 = y1+vsize;
  1179. X     
  1180. X     while (stop == FALSE) {
  1181. X      if ( (xb != max (x1, x2)) || (yb != max (y1, y2))
  1182. X          ||(xa != min (x1, x2)) || (ya != min (y1, y2)) ) {
  1183. X           xa = min (x1, x2);
  1184. X           ya = min (y1, y2);
  1185. X           xb = max (x1, x2);
  1186. X           yb = max (y1, y2);
  1187. X           for ( i = 0; i < PCOUNT; i += 4) {
  1188. X                    box[i].x = xa; box[i].y = ya;
  1189. X                    if (i+1 == PCOUNT) break;
  1190. X                    box[i+1].x = xb; box[i+1].y = ya;
  1191. X                    box[i+2].x = xb; box[i+2].y = yb;
  1192. X                    box[i+3].x = xa; box[i+3].y = yb;
  1193. X           }
  1194. X           doit = TRUE;
  1195. X      }
  1196. X      if (changed) {
  1197. X           int Hsize = (hsize - width_offset) / xinc;
  1198. X           int Vsize = (vsize - height_offset) / yinc;
  1199. X           int pos = 3;
  1200. X           
  1201. X           changed = FALSE;
  1202. X           text[nz - 7] = (Hsize>99) ? (Hsize / 100 + zero)    : ' ';
  1203. X           text[nz - 6] = (Hsize>9)  ? ((Hsize / 10) % 10 + zero)  : ' ';
  1204. X           text[nz - 5] = Hsize % 10 + zero;
  1205. X           if (Vsize>99) text[nz - pos--] = Vsize / 100 + zero;
  1206. X           if (Vsize>9)  text[nz - pos--] = (Vsize / 10) % 10 + zero;
  1207. X           text[nz - pos--]     = Vsize % 10 + zero;
  1208. X           while (pos>0) text[nz - pos--] = ' ';
  1209. X           XDrawImageString(dpy, pop, PopGC, IBW, IBW+PFontInfo->ascent,
  1210. X                text, nz);
  1211. X      }
  1212. X      if (doit) {
  1213. X           XDrawLines(dpy, RootWindow(dpy, scr), invertGC, box, PCOUNT, 
  1214. X              CoordModeOrigin);
  1215. X      }
  1216. X      if (XPending(dpy) &&
  1217. X          XCheckMaskEvent(dpy, ButtonPressMask|ButtonReleaseMask, &e)) {
  1218. X           if ((chosen < 0) && (e.type == ButtonPress)) {
  1219. X            x1 = x2 = ((XButtonEvent *)&e)->x;
  1220. X            y1 = y2 = ((XButtonEvent *)&e)->y;
  1221. X            chosen = ((XButtonEvent *)&e)->button;
  1222. X            if (chosen == Button2)
  1223. X             change_cursor = TRUE;
  1224. X           }
  1225. X           else if ((e.type == ButtonRelease) &&
  1226. X                        ((((XButtonEvent *)&e)->button) == chosen)) {
  1227. X            x2 = ((XButtonEvent *)&e)->x;
  1228. X            y2 = ((XButtonEvent *)&e)->y;
  1229. X            stop = TRUE;
  1230. X           }
  1231. X           else
  1232. X            XQueryPointer (dpy, RootWindow(dpy, scr), &root, 
  1233. X                   &subw, &rootx, &rooty, &x2, &y2, &mask);
  1234. X      }
  1235. X      else        XQueryPointer (dpy, RootWindow(dpy, scr), &root, 
  1236. X                     &subw, &rootx, &rooty, &x2, &y2, &mask);
  1237. X      if (change_cursor) {
  1238. X           if ((x2 >= x1) && (y2 >= y1) &&
  1239. X           current_cursor != lr) {
  1240. X                    XChangeActivePointerGrab (dpy, events, lr, CurrentTime );
  1241. X                    current_cursor = lr;
  1242. X               }
  1243. X           else if ((x2 >= x1) && (y2 < y1) &&
  1244. X            current_cursor != ur) {
  1245. X                    XChangeActivePointerGrab (dpy, events, ur, CurrentTime );
  1246. X                    current_cursor = ur;
  1247. X           }
  1248. X           else if ((x2 < x1) && (y2 >= y1) &&
  1249. X            current_cursor != ll) {
  1250. X                    XChangeActivePointerGrab (dpy, events, ll, CurrentTime );
  1251. X                    current_cursor = ll;
  1252. X           }
  1253. X           else if ((x2 < x1) && (y2 < y1) &&
  1254. X            (current_cursor != ul)) {
  1255. X                    XChangeActivePointerGrab (dpy, events, ul, CurrentTime );
  1256. X                    current_cursor = ul;
  1257. X           }
  1258. X      }
  1259. X      if (chosen != Button2) {
  1260. X           x1 = x2;
  1261. X           y1 = y2;
  1262. X           if (chosen >= 0) {
  1263. X            x2 = defwidth;
  1264. X            if (chosen == Button1)
  1265. X             y2 = defheight;
  1266. X            else
  1267. X             y2 = (DisplayHeight(dpy, scr) - y1);
  1268. X            x2 = x1 + x2;
  1269. X            y2 = y1 + y2;
  1270. X           }
  1271. X      }
  1272. X      
  1273. X      dx = max(min(abs (x2 - x1), maxwidth), minwidth);
  1274. X      dx = makemult(dx-minwidth, xinc)+minwidth; 
  1275. X      dy = max(min(abs(y2 - y1), maxheight), minheight);
  1276. X      dy = makemult(dy-minheight, yinc)+minheight; 
  1277. X      
  1278. X      if (hints->flags & PAspect) {
  1279. X           if ((dx * hints->max_aspect.y > dy * hints->max_aspect.x)) {
  1280. X            delta = makemult((dx * hints->max_aspect.y /
  1281. X                      hints->max_aspect.x) - dy, yinc); 
  1282. X            if ((dy + delta) <= maxheight)
  1283. X             dy += delta;
  1284. X            else {
  1285. X             delta = makemult(dx - hints->max_aspect.x
  1286. X                      * dy/hints->max_aspect.y, xinc);
  1287. X             if ((dx - delta) >= minwidth)
  1288. X                  dx -= delta;
  1289. X            }
  1290. X           }
  1291. X           if (dx * hints->min_aspect.y < dy * hints->min_aspect.x) {
  1292. X            delta = makemult((hints->min_aspect.x *
  1293. X                      dy/hints->min_aspect.y) - dx, xinc);
  1294. X            if (dx + delta <= maxwidth)
  1295. X             dx += delta;
  1296. X            else {
  1297. X             delta = makemult(dy - (dx * hints->min_aspect.y /
  1298. X                        hints->min_aspect.x), yinc); 
  1299. X             if ((dy - delta) >= minheight)
  1300. X                  dy -= delta; 
  1301. X            }
  1302. X           }
  1303. X           
  1304. X      }
  1305. X      
  1306. X      if (dx != hsize) {
  1307. X           hsize = dx;
  1308. X           changed = TRUE;
  1309. X      }
  1310. X      if (dy != vsize) {
  1311. X           vsize = dy;
  1312. X           changed = TRUE;
  1313. X      }
  1314. X      if (x2 < x1)
  1315. X           x2 = x1 - dx;
  1316. X      else
  1317. X           x2 = x1 + dx;
  1318. X      
  1319. X      if (y2 < y1)
  1320. X           y2 = y1 - dy;
  1321. X      else
  1322. X           y2 = y1 + dy;
  1323. X     }
  1324. X     XUngrabPointer(dpy, CurrentTime);
  1325. X     
  1326. X     XDestroyWindow (dpy, pop);
  1327. X     XFreeCursor (dpy, ur);
  1328. X     XFreeCursor (dpy, ul);
  1329. X     XFreeCursor (dpy, lr);
  1330. X     XFreeCursor (dpy, ll);
  1331. X     free(name);
  1332. X     free(text);
  1333. X     *x = min(x1, x2);
  1334. X     *y = min(y1, y2);
  1335. X     *width = hsize;
  1336. X     *height = vsize;
  1337. X     XSync(dpy, FALSE);
  1338. X     Leave_void
  1339. X}
  1340. END_OF_FILE
  1341. if test 12196 -ne `wc -c <'RubberBand.c'`; then
  1342.     echo shar: \"'RubberBand.c'\" unpacked with wrong size!
  1343. fi
  1344. # end of 'RubberBand.c'
  1345. fi
  1346. if test -f 'menus/rtlmenu.c' -a "${1}" != "-c" ; then 
  1347.   echo shar: Will not clobber existing file \"'menus/rtlmenu.c'\"
  1348. else
  1349. echo shar: Extracting \"'menus/rtlmenu.c'\" \(9335 characters\)
  1350. sed "s/^X//" >'menus/rtlmenu.c' <<'END_OF_FILE'
  1351. X
  1352. X#ifndef lint
  1353. X     static char sccs_id[] = "@(#)rtlmenu.c    2.1 12/16/87  Siemens Corporate Research and Support, Inc.";
  1354. X#endif
  1355. X
  1356. X
  1357. X/* 
  1358. X  RTL Menu Package Version 1.0
  1359. X  by Joe Camaratta and Mike Berman, Siemens RTL, Princeton NJ, 1987
  1360. X  
  1361. X  rtlmenu.c: interface level for menu package
  1362. X  */
  1363. X
  1364. X#include "X11/copyright.h"
  1365. X/*
  1366. X *
  1367. X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
  1368. X *
  1369. X * Copyright 1987 by Jordan Hubbard.
  1370. X *
  1371. X *
  1372. X *                         All Rights Reserved
  1373. X *
  1374. X * Permission to use, copy, modify, and distribute this software and its
  1375. X * documentation for any purpose and without fee is hereby granted,
  1376. X * provided that the above copyright notice appear in all copies and that
  1377. X * both that copyright notice and this permission notice appear in
  1378. X * supporting documentation, and that the name of Ardent Computer
  1379. X * Corporation or Jordan Hubbard not be used in advertising or publicity
  1380. X * pertaining to distribution of the software without specific, written
  1381. X * prior permission.
  1382. X *
  1383. X */
  1384. X
  1385. X/*
  1386. X  
  1387. X  Copyright 1987 by
  1388. X  Siemens Corporate Research and Support, Inc., Princeton, New Jersey
  1389. X  
  1390. X  Permission to use, copy, modify, and distribute this software
  1391. X  and its documentation for any purpose and without fee is
  1392. X  hereby granted, provided that the above copyright notice
  1393. X  appear in all copies and that both that copyright notice and
  1394. X  this permission notice appear in supporting documentation, and
  1395. X  that the name of Siemens not be used in advertising or
  1396. X  publicity pertaining to distribution of the software without
  1397. X  specific, written prior permission.  Siemens makes no
  1398. X  representations about the suitability of this software for any
  1399. X  purpose.  It is provided "as is" without express or implied
  1400. X  warranty.
  1401. X  
  1402. X  */
  1403. X
  1404. X#include <stdio.h>
  1405. X#include "X11/Xlib.h"
  1406. X
  1407. X#include "menu.h"
  1408. X#include "menu.def.h"
  1409. X#include "menu.ext.h"
  1410. X#include "rtlmenu.h"
  1411. X#include "dbug.h"
  1412. X
  1413. Xextern Display *dpy;
  1414. Xextern int scr;
  1415. X
  1416. Xstatic RTLPoint menu_pos;
  1417. Xstatic int initialized = 0;
  1418. X     
  1419. Xvoid RTLMenu_Initialize (options_mask)
  1420. XMenuOptionsMask options_mask;
  1421. X{
  1422. X     Entry("RTLMenu_Initialize")
  1423. X
  1424. X     if (initialized)
  1425. X      return;
  1426. X     initialized = 1;
  1427. X     InitMenu ("awm", options_mask);
  1428. X     Leave_void
  1429. X}
  1430. X
  1431. X/* ------------------------------------------------------------ */
  1432. XRTLMenu RTLMenu_Create()
  1433. X{
  1434. X     Entry("RTLMenu_Create")
  1435. X     /* Create a menu with no name, not in inverse video. */
  1436. X     
  1437. X     Leave((RTLMenu)NewMenu())
  1438. X}
  1439. X
  1440. X/* ------------------------------------------------------------ */
  1441. Xvoid RTLMenu_Destroy( menu )
  1442. XRTLMenu menu;
  1443. X{
  1444. X     Entry("RTLMenu_Destroy")
  1445. X     DisposeMenu ((Menu*) menu);
  1446. X     Leave_void
  1447. X}
  1448. X
  1449. X/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
  1450. X
  1451. Xpointer RTLMenu_Data( menu, item )
  1452. X/*ARGSUSED*/
  1453. XRTLMenu menu;
  1454. XRTLMenuItem item;
  1455. X{
  1456. X     Entry("RTLMenu_Data")
  1457. X     Leave(ItemData((MenuItem*)item))
  1458. X}
  1459. X
  1460. X/* ------------------------------------------------------------ */
  1461. X
  1462. XRTLMenu RTLMenu_Get_Submenu( menu, str )
  1463. XRTLMenu menu;
  1464. Xchar *str;
  1465. X{
  1466. X     MenuItem *item = MenuItemByName ((Menu*) menu, str);
  1467. X     Entry("RTLMenu_Get_Submenu")
  1468. X
  1469. X     if (!ItemIsNull(item))
  1470. X      Leave((RTLMenu)ItemSubmenu(item))
  1471. X     Leave(0)
  1472. X}
  1473. X
  1474. X /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
  1475. X
  1476. X/*ARGSUSED*/
  1477. Xstatic void RTLMenu_Client_Send( menu, item )
  1478. XRTLMenu menu;
  1479. XRTLMenuItem item;
  1480. X{
  1481. X     Entry("RTLMenu_Client_Send")
  1482. X
  1483. X     printf ("RTLMenu_Client_Send not yet implemented for X, string = \"%s\"\n",
  1484. X         (char*) item);
  1485. X     Leave_void
  1486. X}
  1487. X
  1488. X/* ------------------------------------------------------------ */
  1489. X
  1490. XRTLMenuItem RTLMenu_Append_String( menu, str, strval )
  1491. XRTLMenu menu;
  1492. Xchar *str;
  1493. Xchar *strval;
  1494. X{
  1495. X     MenuItem *item = AddMenuItem((Menu*)menu, str, (char *)NULL);
  1496. X     Entry("RTLMenu_Append_String")
  1497. X
  1498. X     ItemCallback(item) = (Callback)RTLMenu_Client_Send;
  1499. X     ItemData(item) = (pointer) strval;
  1500. X     Leave((RTLMenuItem)item)
  1501. X}
  1502. X
  1503. X/* ------------------------------------------------------------ */
  1504. X
  1505. XRTLMenuItem RTLMenu_Append_Callback( menu, backproc )
  1506. XRTLMenu menu;
  1507. XVoidFunc backproc;
  1508. X{
  1509. X     MenuItem *item = AddMenuItem((Menu*)menu, "", (char *)NULL);
  1510. X     Entry("RTLMenu_Append_Callback")
  1511. X
  1512. X     ItemGenerator(item) = (Callback)backproc;
  1513. X     
  1514. X     Leave((RTLMenuItem)item)
  1515. X}
  1516. X
  1517. X /* ------------------------------------------------------------ */
  1518. X
  1519. XRTLMenuItem RTLMenu_Append_Call( menu, str, pix, proc, ptrval )
  1520. XRTLMenu menu;
  1521. Xchar *str;
  1522. Xchar *pix;
  1523. XVoidFunc proc;
  1524. Xpointer ptrval;
  1525. X{
  1526. X     MenuItem *item = AddMenuItem((Menu*)menu, str, pix);
  1527. X     
  1528. X     Entry("RTLMenu_Append_Call")
  1529. X
  1530. X     ItemCallback(item) = proc;
  1531. X     ItemData(item) = ptrval;
  1532. X     
  1533. X     Leave((RTLMenuItem)item)
  1534. X}
  1535. X
  1536. X/* ------------------------------------------------------------ */
  1537. X
  1538. XRTLMenuItem RTLMenu_Append_Checkback( menu, str, pix, checkproc, proc, ptrval )
  1539. XRTLMenu menu;
  1540. Xchar *str;   /* Menu string */
  1541. Xchar *pix;
  1542. XBoolean (*checkproc) ();  /* Boolean function called when menu entry
  1543. X              is about to be displayed.  If true, then
  1544. X              the item appears checked; if false, then
  1545. X              it does not */
  1546. XVoidFunc proc;  /* function to be called when the item 
  1547. X           is selected */
  1548. Xpointer ptrval; /* data associated with this item */
  1549. X{
  1550. X     MenuItem *item = AddMenuItem((Menu*)menu, str, pix);
  1551. X     Entry("RTLMenu_Append_Checkback")
  1552. X
  1553. X     ItemCallback(item) = proc;
  1554. X     ItemData(item) = ptrval;
  1555. X     ItemCheckproc(item) =  checkproc;
  1556. X     
  1557. X     Leave((RTLMenuItem)item)
  1558. X}
  1559. X/* ------------------------------------------------------------ */
  1560. X
  1561. XRTLMenuItem RTLMenu_Append_Submenu( menu, str, pix, submenu )
  1562. XRTLMenu menu;
  1563. Xchar *str;
  1564. Xchar *pix;
  1565. XRTLMenu submenu;
  1566. X{
  1567. X     MenuItem *item = AddMenuItem((Menu*)menu, str, pix);
  1568. X     Entry("RTLMenu_Append_Submenu")
  1569. X
  1570. X     ItemSubmenu(item) = (Menu*)submenu;
  1571. X     
  1572. X     Leave((RTLMenuItem)item)
  1573. X}
  1574. X
  1575. X /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
  1576. X
  1577. Xvoid RTLMenu_Replace_Data_Keyed_String( menu, data, str )
  1578. XRTLMenu menu;
  1579. Xpointer data;
  1580. Xchar *str;
  1581. X{
  1582. X     MenuItem *item = MenuItemByName((Menu*) menu, str);
  1583. X     Entry("RTLMenu_Replace_Keyed_String")
  1584. X
  1585. X     if (!ItemIsNull(item))
  1586. X      ItemData(item) = data;
  1587. X     Leave_void
  1588. X} 
  1589. X
  1590. X/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
  1591. X
  1592. Xvoid RTLMenu_Activate_Entry( menu, item )
  1593. XRTLMenu menu;
  1594. XRTLMenuItem item;
  1595. X{
  1596. X     Entry("RTLMenu_Activate_Entry")
  1597. X
  1598. X     (void)SetItemDisable((Menu*)menu, (MenuItem*)item, FALSE);
  1599. X     Leave_void
  1600. X}
  1601. X
  1602. X/* ------------------------------------------------------------ */    
  1603. X
  1604. Xvoid RTLMenu_Inactivate_Entry( menu, item )
  1605. XRTLMenu menu;
  1606. XRTLMenuItem item;
  1607. X{
  1608. X     Entry("RTLMenu_Inactivate_Entry")
  1609. X
  1610. X     (void)SetItemDisable((Menu*)menu, (MenuItem*)item, TRUE);
  1611. X     Leave_void
  1612. X}
  1613. X
  1614. Xvoid RTLMenu_Label_Entry( menu, item )
  1615. XRTLMenu menu;
  1616. XRTLMenuItem item;
  1617. X{
  1618. X     Entry("RTLMenu_Label_Entry")
  1619. X
  1620. X     (void)SetItemDeaf((Menu*)menu, (MenuItem*)item, TRUE);
  1621. X     Leave_void
  1622. X}
  1623. X
  1624. X/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
  1625. X
  1626. XBoolean RTLMenu_Has_Data( menu, val )
  1627. XRTLMenu menu;
  1628. Xpointer val;
  1629. X{
  1630. X     MenuItem *item = MenuItemByData((Menu*)menu, val);
  1631. X     Entry("RTLMenu_Has_Data")
  1632. X
  1633. X     Leave(!ItemIsNull(item))
  1634. X}
  1635. X
  1636. X /* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
  1637. X
  1638. Xvoid RTLMenu_Delete_Entries( menu )
  1639. XRTLMenu menu;
  1640. X{
  1641. X     Entry("RTLMenu_Delete_Entries")
  1642. X
  1643. X     while (DisposeItem((Menu*)menu, MenuItems((Menu*)menu)));
  1644. X     Leave_void
  1645. X}
  1646. X
  1647. X/* ------------------------------------------------------------ */
  1648. X
  1649. Xvoid RTLMenu_Delete_String( menu, str )
  1650. XRTLMenu menu;
  1651. Xchar *str;
  1652. X{
  1653. X     MenuItem *item = MenuItemByName((Menu*) menu, str);
  1654. X     
  1655. X     Entry("RTLMenu_Delete_String");
  1656. X
  1657. X     if (!ItemIsNull(item))
  1658. X      (void) DisposeItem ((Menu*)menu, item);
  1659. X     Leave_void
  1660. X}
  1661. X
  1662. X/* ------------------------------------------------------------ */
  1663. X
  1664. Xvoid RTLMenu_Delete_Data( menu, val )
  1665. XRTLMenu menu;
  1666. Xpointer val;
  1667. X{
  1668. X     MenuItem *item = MenuItemByData((Menu*)menu, val);
  1669. X     
  1670. X     Entry("RTLMenu_Delete_Data");
  1671. X
  1672. X     if (!ItemIsNull(item))
  1673. X      (void) DisposeItem((Menu*)menu, item);
  1674. X     Leave_void
  1675. X}
  1676. X
  1677. X/* $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ */
  1678. X
  1679. X/*ARGSUSED*/
  1680. Xvoid RTLMenu_Box( menu )
  1681. XRTLMenu menu;
  1682. X{
  1683. X     /* Commented out */
  1684. X}
  1685. X
  1686. X /* ------------------------------------------------------------ */
  1687. X
  1688. X/*ARGSUSED*/
  1689. Xvoid RTLMenu_Enter( menu, butnum, buttime, base_window, pos )
  1690. XRTLMenu menu;
  1691. Xint butnum;
  1692. XTime buttime;
  1693. XWindow base_window;
  1694. XRTLPoint pos;
  1695. X{
  1696. X     MenuItem *selected;
  1697. X     
  1698. X     Entry("RTLMenu_Enter")
  1699. X
  1700. X     menu_pos = pos;
  1701. X     selected = TrackMenu ((Menu*) menu, menu_pos.x, menu_pos.y,
  1702. X               butnum, base_window, buttime);
  1703. X     if (!ItemIsNull(selected))
  1704. X      (ItemCallback(selected)) (menu, selected, base_window);
  1705. X     Leave_void
  1706. X}
  1707. X/* ------------------------------------------------------------ */
  1708. X
  1709. XRTLPoint RTLMenu_Entry_Pos()
  1710. X{
  1711. X     Entry("RTLMenu_Entry_Pos")
  1712. X     /* menu_pos is a global static that gets set by the call to */
  1713. X     /* XQueryPointer that is used by the TrackMenu call.        */
  1714. X     
  1715. X     Leave(menu_pos)
  1716. X}
  1717. X
  1718. X
  1719. Xvoid RTLMenu_Generate_Items(menu, proc)
  1720. X/* apply VoidFunc proc to each item in the menu, with       */
  1721. X/* arguments menu and menuItem                              */
  1722. XRTLMenu menu;
  1723. XVoidFunc proc;
  1724. X{
  1725. X     MenuItem *item;
  1726. X     
  1727. X     Entry("RTLMenu_Generate_Items")
  1728. X
  1729. X     for (item = MenuItems((Menu*)menu);
  1730. X      !ItemIsNull(item); item = ItemNext(item))
  1731. X     {
  1732. X      (proc)((RTLMenu)menu, (RTLMenuItem)item);
  1733. X     }
  1734. X     Leave_void
  1735. X}
  1736. END_OF_FILE
  1737. if test 9335 -ne `wc -c <'menus/rtlmenu.c'`; then
  1738.     echo shar: \"'menus/rtlmenu.c'\" unpacked with wrong size!
  1739. fi
  1740. # end of 'menus/rtlmenu.c'
  1741. fi
  1742. echo shar: End of archive 7 \(of 12\).
  1743. cp /dev/null ark7isdone
  1744. MISSING=""
  1745. for I in 1 2 3 4 5 6 7 8 9 10 11 12 ; do
  1746.     if test ! -f ark${I}isdone ; then
  1747.     MISSING="${MISSING} ${I}"
  1748.     fi
  1749. done
  1750. if test "${MISSING}" = "" ; then
  1751.     echo You have unpacked all 12 archives.
  1752.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1753. else
  1754.     echo You still need to unpack the following archives:
  1755.     echo "        " ${MISSING}
  1756. fi
  1757. ##  End of shell archive.
  1758. exit 0
  1759. -- 
  1760. Mike Wexler(wyse!mikew)    Phone: (408)433-1000 x1330
  1761. Moderator of comp.sources.x
  1762.